﻿@namespace MduiBlazor
@inherits MduiInputBase<string>

@if (Rows > 1)
{
    <textarea @ref="@Element" class="@Classname" style="@Style" name="@Name" rows="@Rows" required="@Required"
        pattern="@Pattern" maxlength="@MaxLength" placeholder="@Placeholder" disabled="@Disabled" readonly="@Readonly"
        autofocus="@AutoFocus" @attributes="@AdditionalAttributes" value="@BindConverter.FormatValue(CurrentValueAsString)"
    @onchange="@(EventCallback.Factory.CreateBinder<string?>(this, __value => CurrentValueAsString = __value, CurrentValueAsString))"
    @onfocus="@OnInputFocus" @onblur="@OnInputBlur" @oninput="@OnTextInput" />
}
else
{
    <input @ref="@Element" class="@Classname" style="@Style" name="@Name" type="@Type" required="@Required"
        pattern="@Pattern" maxlength="@MaxLength" placeholder="@Placeholder" disabled="@Disabled" readonly="@Readonly"
        autofocus="@AutoFocus" @attributes="@AdditionalAttributes" value="@BindConverter.FormatValue(CurrentValueAsString)"
    @onchange="@(EventCallback.Factory.CreateBinder<string?>(this, __value => CurrentValueAsString = __value, CurrentValueAsString))"
    @onfocus="@OnInputFocus" @onblur="@OnInputBlur" @oninput="@OnTextInput" />
}
@if (MaxLength > 0 && MaxLength <= int.MaxValue)
{
    <div class="mdui-field-counter">
        <span class="mdui-field-counter-inputed">@_wordNumber</span> / @MaxLength
    </div>
}